home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / program / commio0b.zip / _INPUT.PAS < prev    next >
Pascal/Delphi Source File  |  1996-05-14  |  3KB  |  85 lines

  1. unit _input;
  2. {
  3.           This unit is a companion to the COMMIO communications unit.
  4.                 Written by Jason Morriss a.k.a. Lief O'Pardy
  5.  
  6.                   Copyright (C) 1995,1996 by Jason Morriss
  7.  
  8.   This unit was actually written a long time ago for my own programs.  But
  9.   it is needed by the SysKeys unit in order to be able to read the F11 & F12
  10.   keys, since the TP readkey does not reconize those keys.  So i included
  11.   it JUST FOR YOOOOOOOOOOOOOOOOOOOOUUUUWWWwwwww! ;>
  12.  
  13.   If you use the CRT unit along with this unit in your program, make sure
  14.   THIS unit comes AFTER the CRT unit in the main USES statement.
  15.     ie: uses crt,_INPUT,...;
  16.   Since the names of some of the routines in here have the same name as the
  17.   TP counterparts, this assures that these are used instead of the CRT ones.
  18.   if you (for some ungodly reason) want to use the CRT ones at some point
  19.   you can by doing: ch:=crt.readkey; ... got it? good.
  20.  
  21.   NOTE: these are only LOCAL based IO (ofcourse).
  22. }
  23. Interface
  24.  
  25. Type
  26.   KeyToggles = (RShift,LShift,Ctrl,Alt,ScrollLock,NumLock,CapsLock,Ins);
  27.   Status = Set of KeyToggles;
  28. Var
  29.   KeyStatus : Status Absolute $40:$17;
  30. {  CheckBreak : Boolean;{}
  31.  
  32. (*
  33.   You can turn the 3 leds on the keyboard ON and OFF with the KeyStatus
  34.   Variable!  It works like this:
  35.     exclude(KeyStatus,NumLock);   {turn numlock off}
  36.       or KeyStatus:=Keystatus-Numlock;
  37.     include(KeyStatus,CapsLock);  {turn CapsLock on}
  38.       or KeyStatus:=Keystatus+CapsLock;
  39.   As the online help in TP's IDE states:  the Exclude & Include statements
  40.   produce more efficient code, then the other 2 methods.
  41. *)
  42.  
  43. function KeyPressed : Boolean;
  44. {^ For some reason I found that this function will not reconize <control>
  45.    characters.  I will probably update this soon. }
  46. function ReadKey : Char;
  47. function AltDown : boolean;
  48. function ShiftDown : boolean;
  49.  
  50. Implementation
  51.  
  52. (***************************************************************************)
  53. Function KeyPressed : Boolean;
  54. { This function will also be TRUE for F11, F12, 5 (keypad w/ numlock off),
  55.   unlike TP's keypressed. }
  56. Var
  57.   IsThere : Byte;
  58. begin
  59.   Inline($B4/$0B/$CD/$21/$88/$86/>ISTHERE);
  60.   KeyPressed := (IsThere = $FF);
  61. end;
  62. (***************************************************************************)
  63. Function ReadKey : Char;
  64. { This function also reconizes F11, F12, 5 (keypad w/ numlock off), unlike
  65.   TP's Readkey. }
  66. Var
  67.   chrout : Char;
  68. begin
  69.   Inline($B4/$07/$CD/$21/$88/$86/>CHROUT);
  70. {  if CheckBreak and (chrout = #3) then Inline($CD/$23); { do ^C int }
  71.   ReadKey := chrout;
  72. end;
  73. (***************************************************************************)
  74. function AltDown : boolean;
  75. begin
  76.   altdown:=(Alt in keystatus);
  77. end;
  78. (***************************************************************************)
  79. function ShiftDown : boolean;
  80. begin
  81.   ShiftDown:=(LShift in KeyStatus) or (RShift in KeyStatus);
  82. end;
  83. (***************************************************************************)
  84.  
  85. end.